package com.gzk.oeno.business.compare;

import java.util.Comparator;

import com.gzk.oeno.business.recompense.Recompense;

public class RecompenseComparator implements Comparator<Recompense>{

	@Override
	public int compare(Recompense o1, Recompense o2) {
		if (o1 == null && o2 == null)
			return 0;
		if (o1 == null)
			return 1;
		if (o2 == null)
			return -1;
		
		int nameComp = o1.getName().compareToIgnoreCase(o2.getName());
		if (nameComp == 0){
			if (o1.getAnnee() == null && o2.getAnnee() == null)
				return 0;
			if (o1.getAnnee() == null)
				return 1;
			if (o2.getAnnee() == null)
				return -1;
			
			return o1.getAnnee().compareTo(o2.getAnnee());
		}
		return nameComp;
	}

}
